local gangfeng = fk.CreateSkill({
  name = "sxhl__gangfeng",
  tags = {Skill.Compulsory},
})

gangfeng:addEffect(fk.EventPhaseStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(gangfeng.name) and target == player then
      return player.phase == Player.Finish
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    player:turnOver()
    player:drawCards(1 , gangfeng.name)
    local choice = room:askToChoice(target, {
        choices = {"翻面" , "摸两张牌" , "使用任意张伤害牌"},
        skill_name = gangfeng.name
    })
    if choice == "翻面" then
        player:turnOver()
    elseif choice == "摸两张牌" then
        player:drawCards(2 , gangfeng.name)
    else
        local card = player:getCardIds("h")
        if not player.dead and card  then
            local cnt = 0
            for _, id in ipairs(card) do
                if player.dead  then break end
                local cards = Fk:getCardById(id)
                if cards.is_damage_card then
                    local use = room:askToUseRealCard(player, {
                        pattern = { id },
                        skill_name = gangfeng.name,
                        extra_data = {
                        bypass_times = true,
                        expand_pile = { id },
                        extraUse = true,
                        },
                    })
                    if use then
                        cnt = cnt + 1
                    end
                end
            end
            while cnt~=0 do
                local choice = room:askToChoice(target, {
                choices = {"翻面" , "摸两张牌" },
                skill_name = gangfeng.name
                })
                if choice == "翻面" then
                    player:turnOver()
                elseif choice == "摸两张牌" then
                    player:drawCards(2 , gangfeng.name)
                end
                cnt = cnt - 1
            end
        end
    end
  end,
})


Fk:loadTranslationTable{
  ["sxhl__gangfeng"] = "罡锋",
  [":sxhl__gangfeng"] = "<b>锁定技</b>，结束阶段，你翻面并摸一张牌，然后你选择一项：1.翻面；2.摸两张牌；3.使用任意张伤害牌，然后再选择等量次其他选项。",
}

return gangfeng